package com.gin.custom.cust1;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.gin.custom.R;
import com.gin.custom.cust2.TestAdapter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Cust1Activity extends AppCompatActivity implements View.OnClickListener {

    private RecyclerView recyclerView;
    private CustomTabView tabView;
    

    private View btnType1, btnType2, btnType3;

    public static Intent createIntent(Context context) {
        return new Intent(context, Cust1Activity.class);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cust1);
        recyclerView = findViewById(R.id.recycler);
        recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        recyclerView.setAdapter(new TestAdapter());


        btnType1 = findViewById(R.id.type1);
        btnType2 = findViewById(R.id.type2);
        btnType3 = findViewById(R.id.type3);


        btnType1.setOnClickListener(this);
        btnType3.setOnClickListener(this);
        btnType2.setOnClickListener(this);


        tabView = findViewById(R.id.custom_tab);
        CustFilter1View view = new CustFilter1View(this);
        view.setText("第一个");

        CustFilter2View view2 = new CustFilter2View(this);
        view2.setText("第二个");

        CustFilter3View view3 = new CustFilter3View(this);
        view3.setText("第仨个");
        List<View> views = new ArrayList<>();
        views.add(view);
        views.add(view2);
        views.add(view3);
        String[] titles = {"热门", "HOT", "收藏"};
        tabView.setCustomTabViews(Arrays.asList(titles), views);
    }


    @Override
    public void onClick(View v) {
        CustFilter1View view;
        CustFilter2View view2;
        String[] titles;
        CustFilter3View view3;
        switch (v.getId()) {

            case R.id.type2:
                 titles = new String[] {"分类2热门", "分类2HOT", "分类2收藏"};
                view = new CustFilter1View(this);
                view.setText("type222222第一个");

                view2 = new CustFilter2View(this);
                view2.setText("type222222第2个");

                view3 = new CustFilter3View(this);
                view3.setText("type222222第333333个");

                break;

            case R.id.type3:
                view = new CustFilter1View(this);
                view.setText("type333333第一个");

                view2 = new CustFilter2View(this);
                view2.setText("type333333第二个");

                view3 = new CustFilter3View(this);
                view3.setText("type333333第仨个");
                titles = new String[] {"热门3", "HOT3", "收藏3"};
                break;

            case R.id.type1:
            default:
                view = new CustFilter1View(this);
                view.setText("type1第一个");

                view2 = new CustFilter2View(this);
                view2.setText("type1第二个");

                view3 = new CustFilter3View(this);
                view3.setText("type1第仨个");
                titles = new String[] {"热门", "HOT", "收藏"};
                break;


        }
        List<View> views = new ArrayList<>();
        views.add(view);
        views.add(view2);
        views.add(view3);

        tabView.setCustomTabViews(Arrays.asList(titles), views);
    }
}
